<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <button @click="jian">-</button>
        <span>{{num}}</span>
        <button @click="jia">+</button>

        <!-- 1.创建Vue实例时：el(挂载点),data(数据),methods(方法)
        2.v-on指令的作用是绑定事件，简写为@
        3.方法中通过this，关键字获取data中的数据
        4.v-text指令的作用是：设置元素的文本值，简写为{{}}
        5.v-html指令的作用是：设置元素的innerHTML -->
    </div>
    <script>
        var app = new Vue({
            el:'#app',
            data:{
                num:'1'
            },
            methods:{
                jian:function(){
                    if(this.num>0){
                        this.num--;
                    }
                },
                jia:function(){
                    this.num++;
                }
            }
        })
    </script>
</body>
</html>